package businedelegate;

import java.util.Hashtable;

import javax.naming.InitialContext;

import entities.CommonUtils;
import fachada.Fachada;

public class BusineDelegateTienda {

	protected Fachada 			fachada;
	private InitialContext 		initialContext;

	protected BusineDelegateTienda() {
		inicializarContexto();
	}
	
	/**
	 * Se indica url del servidor de aplicaciones
	 *
	 */
	private void inicializarContexto() {
		try{
			String naming = "TiendaZARAServidorEAR/FachadaBean/remote";
			Hashtable<String, String> props = new Hashtable<String, String>();
			props.put(InitialContext.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
			//Url completa de ubicacion del servidor de aplicaciones
			props.put(InitialContext.PROVIDER_URL,"jnp://"+CommonUtils.HOST+":1099");
			//props.put(InitialContext.PROVIDER_URL,"jnp://172.16.171.116:1099");
			//Objeto del tipo InitialContext
			initialContext = new InitialContext(props);
			fachada = (Fachada) initialContext.lookup(naming);
		}catch(Exception ex){
			System.out.println(ex.getMessage());
			ex.printStackTrace();
		}
	}
}
